#include<bits/stdc++.h>
using namespace std;
const int N = 4e5+5;
typedef long long ll;
ll a[N], b[N];
int n, len;
bool vis[N];
int chainlen=0;
set<int> s;
set<int>::iterator t1, t2;
void solve(int idx){
    int val = a[idx];
    if(s.count(val)) s.erase(val);
    else s.insert(val);
    ll nowlft=0, nowrgt=0;
    ll allans=0;
    ll alll=0, allr = 0;
    t1 = s.begin();
    t2 = s.end();
    t2 --;
    for(;t1!=s.end();t1++, t2--){
        // cout<<b[*t1]<<" -> "<<b[*t2]<<'\n';
        alll += b[*t1], allr += b[*t2];
        if(alll > nowrgt){
            nowlft = alll, nowrgt = allr;
            allans += nowrgt - nowlft;
        }else{
            allans += allr - nowrgt;
            nowrgt = allr;
        }
    }
    cout<<allans<<'\n';
}
int main(){
    freopen("kte.in", "r", stdin);
    freopen("kte.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i] = a[i];
    }
    len = n;
    sort(b+1, b+1+n);
    len = unique(b+1, b+1+n) - b - 1;
    for(int i=1;i<=n;i++){
        a[i] = lower_bound(b+1, b+1+len, a[i]) - b;
    }
    for(int i=1;i<=n;i++){
        solve(i);
    }
}